package math.calcul;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public class ReadWriteFile {
    ///home/me/Documents/ToWindows/model.txt

    public static void writeTextToFile(String texttowrite, String fileadress) {
        try {
            FileWriter fw = new FileWriter(fileadress, false);
            BufferedWriter output = new BufferedWriter(fw);
            output.write(texttowrite);
            output.flush();
            output.close();
        } catch (IOException ioe) {
            System.out.println("error " + ioe);
        }
    }

    public static void writeTextToFile(List<Polyn> solution, String fileadress) {
        String ret = "";
        double[] coeffTs;
        for (Polyn P : solution) {
            coeffTs = P.getCoeffT();
            for (double d : coeffTs) {
                ret += Double.toString(d) + ",";
            }
            ret += "\n";
        }

        writeTextToFile(ret, fileadress);
    }
}


